package com.sparrow.source.controller.third;

import com.sparrow.source.common.dto.Result;
import com.sparrow.source.common.dto.convert.FeiYouConvert;
import com.sparrow.source.third.FeiYouClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author bryceyung
 * @since 2024/11/16
 */
@Controller
@RequestMapping("/feiyou")
public class FeiYouController {

    @Autowired
    private FeiYouClient feiYouClient;

    @Autowired
    private FeiYouConvert feiYouConvert;

    /**
     * 用户初始化--手动
     *
     * @return
     */
    @GetMapping("init")
    @ResponseBody
    public Result userInit() {
        return feiYouConvert.convertFeiYouResponse(feiYouClient.getAllUserData());
    }

    @GetMapping("userIncrementData")
    @ResponseBody
    public Result userIncrementData() {
        return feiYouConvert.convertFeiYouResponse(feiYouClient.userIncrementingData());
    }

    @PostMapping("isOnDuty")
    @ResponseBody
    public Result isOnDuty(@RequestParam("uid") String uid) {
        return feiYouConvert.convertFeiYouResponse(feiYouClient.isOnDuty(uid));
    }
}
